---
title: 'Environment Variables'
description: "Environment variables required to run BaseAI."
tags:
    - baseai
    - environment variables
    - langbase
section: 'Getting Started'
published: 2024-09-24
modified: 2024-09-24
---

# Environment Variables

---

## Overview

BaseAI requires several environment variables to work e.g. your `LANGBASE_API_KEY` or LLM keys. You can create `.env` file in the root of your project and add the required environment variables.

<Note>
If your env file is not named `.env` you will need to add the `envFilePath` property to your `baseai.config.ts` file in the baseai directory. For example: `envFilePath: '.env.local'` and example of this is shown in our Next.js example [baseai config file](https://github.com/LangbaseInc/baseai/blob/main/examples/nextjs/baseai/baseai.config.ts). Paths are relative to the root of your project.
</Note>

<Warn>
Please make sure to add `.env` to the `.gitignore` file of your project. This is to avoid committing your API keys to the git repository accidentally.
</Warn>

---

### Environment Variables

You generally always need your [user or org Langbase API key](https://langbase.com/docs/api-reference/api-keys) called `LANGBASE_API_KEY` (required both in production and local env files). You will also need to add the API keys for the providers you are using in your `pipes` to your local env file.

<Note>
Provider keys are only needed to run pipes locally. In production you should add your provider API keys to your Langbase LLM Keysets (which can be org, user, or pipe level).

Read more about [Langbase LLM Keysets](https://langbase.com/docs/features/keysets).
</Note>

```shell {{ title: '.env file' }}
# !! SERVER SIDE ONLY !!
# Keep all your API keys secret — use only on the server side.

# TODO: ADD: Both in your production and local env files.
# Langbase API key for your User or Org account.
# How to get this API key https://langbase.com/docs/api-reference/api-keys
LANGBASE_API_KEY=

# TODO: ADD: LOCAL ONLY. Add only to local env files.
# Following keys are needed for local pipe runs. Add keys of providers you are using.
# For Langbase, please add the keys in your LLM keysets on Langbase Studio.
# Read more: Langbase LLM Keysets https://langbase.com/docs/features/keysets
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
COHERE_API_KEY=
FIREWORKS_API_KEY=
GOOGLE_API_KEY=
GROQ_API_KEY=
MISTRAL_API_KEY=
PERPLEXITY_API_KEY=
TOGETHER_API_KEY=
```

Once you have added the environment variables, you will be able to run your AI `pipes` locally.

---

### Memory

BaseAI and Langbase uses OpenAI to generate embeddings of the documents present in the memory. Make sure to have `OPENAI_API_KEY` in your local environment variables.

<Note>
You can also use Ollama to create embeddings for free on your local machince. Read more on how to [Use Ollama for Embeddings](https://baseai.dev/docs/memory/ollama-embeddings)
</Note>

---
